<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机图片</title>
</head>
<body>
<!-- 小图 -->
<div style="background-color:red;border: dotted; height: 50px; width: 50px">
    <img src="img/01.jpg" id="small" style="width: 50px; height: 50px;">
</div>
<!-- 大图 -->
<div style="border: double ;width: 400px; height: 400px; position: absolute; left: 500px; top:10px">
    <img src="" id="big" style="width: 400px; height: 400px; display:none;">
</div>

<!-- 开始和结束按钮 -->
<input id="startBtn" type="button" style="width: 150px;height: 150px; font-size: 20px" value="开始">
<input id="stopBtn" type="button" style="width: 150px;height: 150px; font-size: 20px" value="停止">
</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
    //1.准备一个数组
    let imgs = [
        "img/01.jpg",
        "img/02.jpg",
        "img/03.jpg",
        "img/04.jpg",
        "img/05.jpg",
        "img/06.jpg",
        "img/07.jpg",
        "img/08.jpg",
        "img/09.jpg",
        "img/10.jpg"];
		
    //2.定义计数器
    let timeId;
    let idx=0;
    function lb(){
      idx++;
      idx=idx%imgs.length;
      $("#small").prop("src",imgs[idx]);
    };
    //3.定义定时器对象
    $("#startBtn").click(function(){
        timeId=setInterval(lb,50);
        $("#startBtn").prop("disabled",true);
        $("#stopBtn").prop("disabled",false);
    });
   //取消定时器
    $("#stopBtn").click(function(){
        clearInterval(timeId);
        $("#stopBtn").prop("disabled",true);
        $("#startBtn").prop("disabled",false);
        $("#big").prop("src",imgs[idx]).hide().show(1000);
    });
     
</script>
</html>